package cn.ryh.listener.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName SessionController
 * @Description 测试Session监听器
 * @Author RaoYH
 */
@Controller
@RequestMapping(value = "/sessionController")
public class SessionController {
    @RequestMapping(value = "/sessionListener")
    public void sessionListener(HttpServletRequest req, HttpServletResponse resp){
        //request.getSession()操作，触发sessionCreated()方法
        req.getSession();
        //触发sessionDestroyed()方法
        req.getSession().invalidate();
    }
}
